package day7.sp;

/**
 * @author oldliu
 * @since 1.0
 */
public class AutoSaveThread extends Thread {
    private final Market market;

    public  AutoSaveThread(Market m){
        this.market=m;
        setDaemon(true);//守护线程
    }

    @Override
    public void run() {
         while (true){
             try {
                 sleep(4000);
                 Market.storeObj(this.market);
             } catch (InterruptedException e) {
                 e.printStackTrace();
             }
         }
    }
}
